]> dgit.raspbian.org Git - dovecot.git/commit
[PATCH 1/7] lib-sieve: Add per-user sieve-rusage file for cumulative CPU tracking
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 5 May 2026 16:18:34 +0000 (16:18 +0000)
committerNoah Meyerhans <noahm@debian.org>
Wed, 16 Sep 2026 19:06:35 +0000 (15:06 -0400)
commit38b546cae160ba22111eff3fe4745fb839edacf0
tree73e33c36c0ba904f9471364d608c8683a962e57d
parentd56d1c4fe3357e09f6bac727472aa2f91ea8797b
[PATCH 1/7] lib-sieve: Add per-user sieve-rusage file for cumulative CPU tracking

Cumulative resource usage was previously stored in each compiled Sieve
binary's (.svbin) header. Because the binary file is keyed by script
name, a user could reset their CPU budget by uploading the same script
under a different name (PUTSCRIPT newname + SETACTIVE newname),
RENAMESCRIPT, or DELETESCRIPT followed by PUTSCRIPT under another
name. Each such operation produced a fresh .svbin with zero counter,
allowing the sieve_max_cpu_time limit to be bypassed indefinitely.

Track cumulative CPU per user instead, in <INBOX-namespace-root>/sieve-rusage.
The file persists across all script renames, deletions, and re-uploads,
since it is not tied to any particular script name. Tracking is enabled
only for personal storages where the user's INBOX namespace has a
filesystem path; admin/default storages are unaffected here.

The on-disk format is a single ASCII line:

    V1 <flags> <cpu-secs> <update-time>

CPU time is rounded up to whole seconds when persisted; sub-second
precision is preserved only for the in-memory accumulation within a
single execution. The file is updated by writing a new copy via
file_dotlock_open_mode() and replacing the original via
file_dotlock_replace(). Concurrent writers are serialized through the
dotlock; readers do not need a lock because the rename is atomic.

The .svbin header still carries its original resource_usage struct as
the active fallback when no per-user file is available; a follow-up
commit drops that path.

Gbp-Pq: Name 0001-lib-sieve-Add-per-user-sieve-rusage-file-for-cumulat.patch
pigeonhole/src/lib-sieve/Makefile.am
pigeonhole/src/lib-sieve/sieve-binary-file.c
pigeonhole/src/lib-sieve/sieve-binary.c
pigeonhole/src/lib-sieve/sieve-binary.h
pigeonhole/src/lib-sieve/sieve-rusage.c [new file with mode: 0644]
pigeonhole/src/lib-sieve/sieve-rusage.h [new file with mode: 0644]
pigeonhole/src/lib-sieve/sieve-storage-private.h
pigeonhole/src/lib-sieve/sieve-storage.c
pigeonhole/src/lib-sieve/sieve.c